package com.cby.android.library.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import com.cby.android.library.R

abstract class BaseActivity : AppCompatActivity() {

    var toolbar: Toolbar? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getLayoutId())
        parseArgs()
        initToolBar()
        onViewInit()
        onDataInit()
    }

    open fun parseArgs() {

    }

    fun initToolBar() {
        toolbar = findViewById(R.id.toolbar)
        toolbar?.apply {
            setSupportActionBar(toolbar)
            supportActionBar!!.setDisplayHomeAsUpEnabled(true)
            setNavigationOnClickListener { finish() }
        }
    }

    protected abstract fun getLayoutId():Int

    protected abstract fun onViewInit()

    protected abstract fun onDataInit()


}